﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LevenBlog.Core.Entities;

namespace LevenBlog.Core.WebService.Entities
{
    [Serializable]
    public class FullUser : User
    {
        public int InfoID { get; set; }

        public string Mail { get; set; }

        public string NickName { get; set; }

        public short Sex { get; set; }

        public string Face { get; set; }

        public string Signature { get; set; }

        public DateTime RegTime { get; set; }

        public string RegIp { get; set; }

        public DateTime LastLoginTime { get; set; }

        public string LastLoginIp { get; set; }

        public virtual void FillWithDbEntity(lb_user user, lb_userinfo info)
        {
            base.FillWithDbEntity(user);
            InfoID = info.id;
            Mail = info.mail;
            NickName = info.nickname;
            Sex = info.sex;
            Face = info.face;
            Signature = info.signature;
            RegTime = info.regtime;
            RegIp = info.regip;
            LastLoginIp = info.lastloginip;
            LastLoginTime = info.lastlogintime;
        }

        public override lb_user ToEntity()
        {
            lb_user user = base.ToEntity();
            user.userinfo = new lb_userinfo();
            user.userinfo.face = Face;
            user.userinfo.id = ID;
            user.userinfo.lastloginip = LastLoginIp;
            user.userinfo.lastlogintime = LastLoginTime;
            user.userinfo.mail = Mail;
            user.userinfo.nickname = NickName;
            user.userinfo.regip = RegIp;
            user.userinfo.regtime = RegTime;
            user.userinfo.sex = Sex;
            user.userinfo.signature = Signature;
            return user;
        }
    }
}
